package cn.yudao.ymcc.service.impl;

import cn.yudao.ymcc.domain.UserCode;
import cn.yudao.ymcc.dto.UserInfoParamDto;
import cn.yudao.ymcc.logincontext.LoginContext;
import cn.yudao.ymcc.mapper.UserCodeMapper;
import cn.yudao.ymcc.service.IUserCodeService;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author whale.jia
 * @since 2022-08-08
 */
@Service
public class UserCodeServiceImpl extends ServiceImpl<UserCodeMapper, UserCode> implements IUserCodeService {

    @Override
    public String loadCode() {
        UserInfoParamDto userInfoParamDto = LoginContext.getUserInfoParamDto();
        Wrapper<UserCode> warpper = new EntityWrapper<>();
        warpper.eq("user_id",userInfoParamDto.getId());
        UserCode userCode = selectOne(warpper);
        return userCode.getCode();
    }
}
